<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link rel="stylesheet" type="text/css" href="css/add.css"/>
    <script type="text/javascript" src="js/jquery.1.9.1.js" ></script>
    <script type="text/javascript" src="js/layer.js" ></script>
    <link rel="stylesheet" type="text/css" href="css/layer.css"/>
    <script type="text/javascript" src="js/iScroll.js" ></script>
    <script type="text/javascript" src="js/Mdate.js" ></script>
	<link rel="stylesheet" href="css/Mdate.css" />
	<script type="text/javascript" src="js/rem.js" ></script>
    <title>新增供应商</title>
</head>
<body>
<form id="form2" action="" enctype="multipart/form-data"  method="post">
<ul class="order_money" style="padding: 0 0.3rem;background: #fff;">
	<li>
    		<span class="chang">供应商名称</span>
    		<span class="jt"></span>
    		<select class="session">
    			<option value="0">必填</option>
    			<option value="111">供应商1</option>
    			<option value="2222">供应商2</option>
    			<option value="3333">供应商3</option>
    		</select>
    </li>
    <li>
    		<span class="num">供应商编号</span>
    		<input type="text" name="" id="week" value="" />
    </li>
    <li>
    		<span class="address">地址</span>
    		<textarea id="address" placeholder="请输入地址"></textarea>
    </li>
    <li>
    		<span class="cg">供货类别</span>
    		<span class="jt"></span>
    		<select class="caigou">
    			<option value="0">必填</option>
    			<option value="1">类别1</option>
    			<option value="2">类别2</option>
    			<option value="3">类别3</option>
    		</select>
    </li>
</ul>
<div class="contact">联系人信息</div>
<ul class="beizhu">
	<li>
    		<span class="name">姓名</span>
    		<span class="jt"></span>
    		<select class="person">
    			<option value="0">必填</option>
    			<option value="1">姓名1</option>
    			<option value="2">姓名2</option>
    			<option value="3">姓名3</option>
    		</select>
    </li>
	<li>
    		<span class="money">手机号</span>
    		<input type="number" name="" id="money" value="" placeholder="请输入手机号" />
    </li>
	<li style="height: 2.3rem;">
		<p class="title">单据备注</p>
        <textarea class="bei" style="height: 1.3rem;" ></textarea>
    </li>
</ul>
<div class="button">
		<a href="#"><div class="close">保存草稿</div></a>
		<div class="continue"><input class="pay" type="submit" name="" id="" value="提交审批" /></div>
</div>

</form>
<script>//提交表单
$(function(){
	$('.pay').click(function(){
		var supplier = $('.session').val();
		var num = $('#week').val();
		var address = $('#address').val();
		var category = $('.caigou').val();
		var name = $('.person').val();
		var tel = $('#money').val();
		var txt = $('.bei').val();
		if(supplier == 0){
				layer.open({
				content:'请选择供应商' ,
				skin: 'msg',
				time: 2 //2秒后自动关闭
			});
			return false
		}
		if(num == ''||num == null){
				layer.open({
				content:'请输入供应商编号' ,
				skin: 'msg',
				time: 2 //2秒后自动关闭
			});
			return false
		}
		if(address == ''||address == null){
				layer.open({
				content:'请输入地址' ,
				skin: 'msg',
				time: 2 //2秒后自动关闭
			});
			return false
		}
		if(category == 0){
				layer.open({
				content:'请选择供货类别' ,
				skin: 'msg',
				time: 2 //2秒后自动关闭
			});
			return false
		}
		if(name == 0){
				layer.open({
				content:'请选择联系人' ,
				skin: 'msg',
				time: 2 //2秒后自动关闭
			});
			return false
		}
		if(!(/^1[3456789]\d{9}$/.test(tel))) {
			layer.open({
				content: '请输入正确的手机号码',
				skin: 'msg',
				time: 2 //2秒后自动关闭
			});
			return false;
		}
		if(txt == ''||txt == null){
				layer.open({
				content:'请填写备注' ,
				skin: 'msg',
				time: 2 //2秒后自动关闭
			});
			return false
		}
		$.ajax({
		  type: 'post',
		  url:"" ,
		  data:{num:num,supplier:supplier,address:address,category:category,name:name,tel:tel,txt:txt},
		  dataType: "json",
		  success: function(data){
		    window.location.href = "cglist.html";
		      }
		 });
	 });
});
</script>
<script>//字体变化
	$('#week').keyup(function(){
		var week = $('#week').val();
		if(week != ''){
			$('.num').css('font-size','0.2rem');
		}else{
			$('.num').css('font-size','0.28rem');
		}
	});
	$('.session').change(function(){
		var session = $('.session').val();
		$('#week').val(session);
		if(session != 0){
			$('.chang').css('font-size','0.2rem');
			$('.num').css('font-size','0.2rem');
		}else{
			$('.chang').css('font-size','0.28rem');
			$('.num').css('font-size','0.28rem');
		}
	});
	$('#address').keyup(function(){
		var address = $('#address').val();
		if(address != ''){
			$('.address').css('font-size','0.2rem');
		}else{
			$('.address').css('font-size','0.28rem');
		}
	});
	$('.caigou').change(function(){
		var caigou = $('.caigou').val();
		if(caigou != 0){
			$('.cg').css('font-size','0.2rem');
		}else{
			$('.cg').css('font-size','0.28rem');
		}
	});
	$('.person').change(function(){
		var person = $('.person').val();
		if(person != 0){
			$('.name').css('font-size','0.2rem');
		}else{
			$('.name').css('font-size','0.28rem');
		}
	});
	$('#money').keyup(function(){
		var money = $('#money').val();
		if(money != ''){
			$('.money').css('font-size','0.2rem');
		}else{
			$('.money').css('font-size','0.28rem');
		}
	});
	$('.bei').keyup(function(){
		var textarea = $('.bei').val();
		if(textarea != ''){
			$('.title').css('font-size','0.2rem');
		}else{
			$('.title').css('font-size','0.28rem');
		}
	});
</script>

</body>
</html>
